﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace MXComponent.Views.system
{
    /// <summary>
    /// SetWindow.xaml 的交互逻辑
    /// </summary>
    public partial class SetWindow2 : Window
    {
        public SetWindow2()
        {
            InitializeComponent();
        }
        public float count = 0;

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void btncancle_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void btnok_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txtReCount.Text))
            {
                MessageBox.Show("请先输入限制重量！");
                txtReCount.Focus();
                return;
            }
            if (!Regex.IsMatch(this.txtReCount.Text, @"^([0-9])[0-9]*(\.\w*)?$"))
            {
                MessageBox.Show("限制重量输入错误,只限数字类型！");
                this.txtReCount.Text = string.Empty;
                txtReCount.Focus();
                return;
            }
            this.count = float.Parse(txtReCount.Text);
            if(count<10|| count> 32.766)
            {
                MessageBox.Show("车次输入错误，范围10~32.766！");
                this.txtReCount.Text = string.Empty;
                txtReCount.Focus();
                return;
            }
            this.DialogResult = true;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.txtReCount.Focus();
        }

        
    }
}
